<#assign pojoNameLower = pojo.shortName.substring(0,1).toLowerCase()+pojo.shortName.substring(1)>
<#assign dateExists = false>
<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html>
<html>
<head>
<%@ include file="/common/links.jsp"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
	$(document).ready(function() {
		$('#submit').click(function() {
			try{
			var subResult = $('#${pojoNameLower}Form').ajaxSubmit(formOptions);
			return false;
			}catch(e){
				alert(e.message);
			}
		})
		$('#cancel').click(function() {
			closePopUpForm();
		})
		$("button").button();
		//$( "#demoEntity_dateField" ).datepicker(datePickerOptions);//TODO here init date field datepicker bind
		 jQuery("#${pojoNameLower}Form").validationEngine({promptPosition : "centerRight"});
	});

</script>
</head>
<body>
	<fieldset>
		<legend>
			<c:if test="${'$'}{editType==1}">
				<s:text name="${pojoNameLower}New.title" />
			</c:if>
			<c:if test="${'$'}{editType==2}">
				<s:text name="${pojoNameLower}Edit.title" />
			</c:if>
		</legend>
		<s:form id="${pojoNameLower}Form" action="save${pojo.shortName}" theme="xhtml" validate="false">
			<s:hidden name="gridId"/>
			<s:hidden name="editType"/>
		<#foreach field in pojo.getAllPropertiesIterator()>
			<#if field.equals(pojo.identifierProperty)>
			    <#assign idFieldName = field.name>
			    <#if field.value.identifierGeneratorStrategy == "assigned">
			<s:textfield key="${pojoNameLower}.${field.name}" required="true" cssClass="validate[required]"/>
			    <#else>
			<s:hidden key="model.${field.name}"/>
			    </#if>
			<#elseif !c2h.isCollection(field) && !c2h.isManyToOne(field) && !c2j.isComponent(field)>
			    <#foreach column in field.getColumnIterator()>
			        <#if field.value.typeName == "boolean" || field.value.typeName == "java.lang.Boolean">
			<s:checkbox id="${pojoNameLower}_${field.name}" key="${pojoNameLower}.${field.name}" name="model.${field.name}" />
			        <#else>
			<s:textfield id="${pojoNameLower}_${field.name}" key="${pojoNameLower}.${field.name}" name="model.${field.name}" required="${(!column.nullable)?string}" cssClass="validate[<#if !column.nullable>required,custom[<#else>custom[</#if><#if  field.value.typeName == "float" || field.value.typeName == "double" ||  field.value.typeName == "java.lang.Float" || field.value.typeName == "java.lang.Double" || field.value.typeName == "java.math.BigDecimal">number</#if><#if  field.value.typeName == "int" || field.value.typeName == "long" ||  field.value.typeName == "short" || field.value.typeName == "java.lang.Integer" || field.value.typeName == "java.lang.Long" || field.value.typeName == "java.lang.Short">integer</#if><#if field.value.typeName == "java.util.Date">date</#if>]]"<#if field.value.typeName == "java.util.Date">><s:param name="value"><s:date name="model.${field.name}" format="%{getText('date.format')}"/></s:param></s:textfield><#else>/></#if>
			        </#if>
			    </#foreach>
			<#elseif c2h.isManyToOne(field)>
			    <#foreach column in field.getColumnIterator()>
			            <#lt/>    <!-- todo: change this to read the identifier field from the other pojo -->
			            <#lt/>    <!-- <s:select name="${pojoNameLower}.${field.name}.id" list="${field.name}List" listKey="id" listValue="id"></s:select> -->
			    </#foreach>
			</#if>
		</#foreach>	
		</s:form>
		<button name="submit" type="button" id="submit">
			<s:text name="button.save" />
		</button>
		<button name="cancel" type="button" id="cancel">
			<s:text name="button.cancel" />
		</button>
	</fieldset>
</body>
</html>





















